home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Devices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  12.3 KB  |  380 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __DEVICES__
  18. #define __DEVICES__
  19.  
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. /*    #include <Types.h>                                            */
  25. /*        #include <ConditionalMacros.h>                            */
  26. /*    #include <MixedMode.h>                                        */
  27. /*    #include <Memory.h>                                            */
  28.  
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32.  
  33. #ifndef __QUICKDRAW__
  34. #include <Quickdraw.h>
  35. #endif
  36. /*    #include <QuickdrawText.h>                                    */
  37.  
  38. #ifndef __EVENTS__
  39. #include <Events.h>
  40. #endif
  41.  
  42. #ifndef __DIALOGS__
  43. #include <Dialogs.h>
  44. #endif
  45. /*    #include <Errors.h>                                            */
  46. /*    #include <Windows.h>                                        */
  47. /*        #include <Controls.h>                                    */
  48. /*            #include <Menus.h>                                    */
  49. /*    #include <TextEdit.h>                                        */
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if GENERATINGPOWERPC
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59. #ifdef __CFM68K__
  60. #pragma lib_export on
  61. #endif
  62.  
  63.  
  64. enum {
  65.     chooserInitMsg                = 11,                            /* the user selected this device package */
  66.     newSelMsg                    = 12,                            /* the user made new device selections */
  67.     fillListMsg                    = 13,                            /* fill the device list with choices */
  68.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  69.     selectMsg                    = 15,                            /* the user made a selection */
  70.     deselectMsg                    = 16,                            /* the user canceled a selection */
  71.     terminateMsg                = 17,                            /* allows device package to clean up */
  72.     buttonMsg                    = 19                            /* the user selected a button */
  73. };
  74.  
  75. /* Values of the 'caller' parameter to a Chooser device package */
  76. enum {
  77.     chooserID                    = 1
  78. };
  79.  
  80. /* Values of the 'message' parameter to a Control Panel 'cdev' */
  81. enum {
  82.     initDev                        = 0,                            /*Time for cdev to initialize itself*/
  83.     hitDev                        = 1,                            /*Hit on one of my items*/
  84.     closeDev                    = 2,                            /*Close yourself*/
  85.     nulDev                        = 3,                            /*Null event*/
  86.     updateDev                    = 4,                            /*Update event*/
  87.     activDev                    = 5,                            /*Activate event*/
  88.     deactivDev                    = 6,                            /*Deactivate event*/
  89.     keyEvtDev                    = 7,                            /*Key down/auto key*/
  90.     macDev                        = 8,                            /*Decide whether or not to show up*/
  91.     undoDev                        = 9,
  92.     cutDev                        = 10,
  93.     copyDev                        = 11,
  94.     pasteDev                    = 12,
  95.     clearDev                    = 13,
  96.     cursorDev                    = 14
  97. };
  98.  
  99. /* Special values a Control Panel 'cdev' can return */
  100. enum {
  101.     cdevGenErr                    = -1,                            /*General error; gray cdev w/o alert*/
  102.     cdevMemErr                    = 0,                            /*Memory shortfall; alert user please*/
  103.     cdevResErr                    = 1,                            /*Couldn't get a needed resource; alert*/
  104.     cdevUnset                    = 3                                /* cdevValue is initialized to this*/
  105. };
  106.  
  107. /* Values of the 'message' parameter to a Monitor 'mntr' */
  108. enum {
  109.     initMsg                        = 1,                            /*initialization*/
  110.     okMsg                        = 2,                            /*user clicked OK button*/
  111.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  112.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  113.     nulMsg                        = 5,                            /*periodic event*/
  114.     updateMsg                    = 6,                            /*update event*/
  115.     activateMsg                    = 7,                            /*not used*/
  116.     deactivateMsg                = 8,                            /*not used*/
  117.     keyEvtMsg                    = 9,                            /*keyboard event*/
  118.     superMsg                    = 10,                            /*show superuser controls*/
  119.     normalMsg                    = 11,                            /*show only normal controls*/
  120.     startupMsg                    = 12                            /*code has been loaded*/
  121. };
  122.  
  123. /* control codes for DeskAccessories */
  124. enum {
  125.     goodbye                        = -1,                            /* heap being reinitialized */
  126.     killCode                    = 1,                            /* KillIO requested */
  127.     accEvent                    = 64,                            /* handle an event */
  128.     accRun                        = 65,                            /* time for periodic action */
  129.     accCursor                    = 66,                            /* change cursor shape */
  130.     accMenu                        = 67,                            /* handle menu item */
  131.     accUndo                        = 68,                            /* handle undo command */
  132.     accCut                        = 70,                            /* handle cut command */
  133.     accCopy                        = 71,                            /* handle copy command */
  134.     accPaste                    = 72,                            /* handle paste command */
  135.     accClear                    = 73                            /* handle clear command */
  136. };
  137.  
  138. /* miscellaneous Device Manager constants */
  139. enum {
  140.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  141.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  142.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  143.     asyncTrpBit                    = 10,                            /* trap word modifier */
  144.     noQueueBit                    = 9                                /* trap word modifier */
  145. };
  146.  
  147. /* flags used in the driver header and device control entry */
  148. enum {
  149.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  150.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  151.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  152.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  153.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  154.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  155.     dNeedLock                    = 6,                            /* set if driver must be locked in memory as soon as it is opened */
  156.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  157.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  158.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  159.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  160.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  161.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  162.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  163. };
  164.  
  165. /* run-time flags used in the device control entry */
  166. enum {
  167.     dOpened                        = 5,                            /* driver is open */
  168.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  169.     drvrActive                    = 7,                            /* driver is currently processing a request */
  170.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  171.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  172.     dOpenedMask                    = 0x0020                        /* driver is open */
  173. };
  174.  
  175. struct DRVRHeader {
  176.     short                            drvrFlags;
  177.     short                            drvrDelay;
  178.     short                            drvrEMask;
  179.     short                            drvrMenu;
  180.     short                            drvrOpen;
  181.     short                            drvrPrime;
  182.     short                            drvrCtl;
  183.     short                            drvrStatus;
  184.     short                            drvrClose;
  185.     unsigned char                    drvrName[1];
  186. };
  187. typedef struct DRVRHeader DRVRHeader;
  188.  
  189. typedef DRVRHeader *DRVRHeaderPtr, **DRVRHeaderHandle;
  190.  
  191. struct DCtlEntry {
  192.     Ptr                                dCtlDriver;
  193.     short                            dCtlFlags;
  194.     QHdr                            dCtlQHdr;
  195.     long                            dCtlPosition;
  196.     Handle                            dCtlStorage;
  197.     short                            dCtlRefNum;
  198.     long                            dCtlCurTicks;
  199.     WindowPtr                        dCtlWindow;
  200.     short                            dCtlDelay;
  201.     short                            dCtlEMask;
  202.     short                            dCtlMenu;
  203. };
  204. typedef struct DCtlEntry DCtlEntry;
  205.  
  206. typedef DCtlEntry *DCtlPtr, **DCtlHandle;
  207.  
  208. struct AuxDCE {
  209.     Ptr                                dCtlDriver;
  210.     short                            dCtlFlags;
  211.     QHdr                            dCtlQHdr;
  212.     long                            dCtlPosition;
  213.     Handle                            dCtlStorage;
  214.     short                            dCtlRefNum;
  215.     long                            dCtlCurTicks;
  216.     GrafPtr                            dCtlWindow;
  217.     short                            dCtlDelay;
  218.     short                            dCtlEMask;
  219.     short                            dCtlMenu;
  220.     SInt8                            dCtlSlot;
  221.     SInt8                            dCtlSlotId;
  222.     long                            dCtlDevBase;
  223.     Ptr                                dCtlOwner;
  224.     SInt8                            dCtlExtDev;
  225.     SInt8                            fillByte;
  226.     UInt32                            dCtlNodeID;
  227. };
  228. typedef struct AuxDCE AuxDCE;
  229.  
  230. typedef AuxDCE *AuxDCEPtr, **AuxDCEHandle;
  231.  
  232. typedef pascal long (*ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
  233.  
  234. #if GENERATINGCFM
  235. typedef UniversalProcPtr ControlPanelDefUPP;
  236. #else
  237. typedef ControlPanelDefProcPtr ControlPanelDefUPP;
  238. #endif
  239.  
  240. enum {
  241.     uppControlPanelDefProcInfo = kPascalStackBased
  242.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  243.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  244.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  245.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  246.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  247.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord*)))
  248.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long)))
  249.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr)))
  250. };
  251.  
  252. #if GENERATINGCFM
  253. #define NewControlPanelDefProc(userRoutine)        \
  254.         (ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentArchitecture())
  255. #else
  256. #define NewControlPanelDefProc(userRoutine)        \
  257.         ((ControlPanelDefUPP) (userRoutine))
  258. #endif
  259.  
  260. #if GENERATINGCFM
  261. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  262.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  263. #else
  264. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  265.         (*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  266. #endif
  267.  
  268. extern pascal DCtlHandle GetDCtlEntry(short refNum);
  269. /*
  270.     SetChooserAlert used to simply set a bit in a low-mem global
  271.     to tell the Chooser not to display its warning message when
  272.     the printer is changed. However, under MultiFinder and System 7,
  273.     this low-mem is swapped out when a layer change occurs, and the
  274.     Chooser never sees the change. It is obsolete, and completely
  275.     unsupported on the PowerPC. 68K apps can still call it if they
  276.     wish.
  277. */
  278. #if OLDROUTINENAMES && !GENERATINGCFM
  279. extern pascal Boolean SetChooserAlert(Boolean f);
  280. #endif
  281. /*
  282.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  283.           There will soon be a DriverInstall() which does the right thing.
  284.  
  285.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  286.         still exports DrvrRemove, so a macro is used to map the new name to old.
  287.  
  288. */
  289.  
  290. #if !GENERATINGCFM
  291. #pragma parameter __D0 DrvrRemove(__D0)
  292. #endif
  293. extern pascal OSErr DrvrRemove(short refNum)
  294.  ONEWORDINLINE(0xA03E);
  295. #define DriverRemove(refNum) DrvrRemove(refNum)
  296. extern pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
  297. extern pascal OSErr CloseDriver(short refNum);
  298. extern pascal OSErr Control(short refNum, short csCode, const void *csParamPtr);
  299. extern pascal OSErr Status(short refNum, short csCode, void *csParamPtr);
  300. extern pascal OSErr KillIO(short refNum);
  301.  
  302. #if !GENERATINGCFM
  303. #pragma parameter __D0 PBControlSync(__A0)
  304. #endif
  305. extern pascal OSErr PBControlSync(ParmBlkPtr paramBlock)
  306.  ONEWORDINLINE(0xA004);
  307.  
  308. #if !GENERATINGCFM
  309. #pragma parameter __D0 PBControlAsync(__A0)
  310. #endif
  311. extern pascal OSErr PBControlAsync(ParmBlkPtr paramBlock)
  312.  ONEWORDINLINE(0xA404);
  313.  
  314. #if !GENERATINGCFM
  315. #pragma parameter __D0 PBControlImmed(__A0)
  316. #endif
  317. extern pascal OSErr PBControlImmed(ParmBlkPtr paramBlock)
  318.  ONEWORDINLINE(0xA204);
  319.  
  320. #if !GENERATINGCFM
  321. #pragma parameter __D0 PBStatusSync(__A0)
  322. #endif
  323. extern pascal OSErr PBStatusSync(ParmBlkPtr paramBlock)
  324.  ONEWORDINLINE(0xA005);
  325.  
  326. #if !GENERATINGCFM
  327. #pragma parameter __D0 PBStatusAsync(__A0)
  328. #endif
  329. extern pascal OSErr PBStatusAsync(ParmBlkPtr paramBlock)
  330.  ONEWORDINLINE(0xA405);
  331.  
  332. #if !GENERATINGCFM
  333. #pragma parameter __D0 PBStatusImmed(__A0)
  334. #endif
  335. extern pascal OSErr PBStatusImmed(ParmBlkPtr paramBlock)
  336.  ONEWORDINLINE(0xA205);
  337.  
  338. #if !GENERATINGCFM
  339. #pragma parameter __D0 PBKillIOSync(__A0)
  340. #endif
  341. extern pascal OSErr PBKillIOSync(ParmBlkPtr paramBlock)
  342.  ONEWORDINLINE(0xA006);
  343.  
  344. #if !GENERATINGCFM
  345. #pragma parameter __D0 PBKillIOAsync(__A0)
  346. #endif
  347. extern pascal OSErr PBKillIOAsync(ParmBlkPtr paramBlock)
  348.  ONEWORDINLINE(0xA406);
  349.  
  350. #if !GENERATINGCFM
  351. #pragma parameter __D0 PBKillIOImmed(__A0)
  352. #endif
  353. extern pascal OSErr PBKillIOImmed(ParmBlkPtr paramBlock)
  354.  ONEWORDINLINE(0xA206);
  355. extern pascal short OpenDeskAcc(ConstStr255Param deskAccName)
  356.  ONEWORDINLINE(0xA9B6);
  357. extern pascal void CloseDeskAcc(short refNum)
  358.  ONEWORDINLINE(0xA9B7);
  359. #if CGLUESUPPORTED
  360. extern short opendeskacc(const char *deskAccName);
  361. extern OSErr opendriver(const char *driverName, short *refNum);
  362. #endif
  363. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  364. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  365. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  366.  
  367. #ifdef __CFM68K__
  368. #pragma lib_export off
  369. #endif
  370.  
  371. #if GENERATINGPOWERPC
  372. #pragma options align=reset
  373. #endif
  374.  
  375. #ifdef __cplusplus
  376. }
  377. #endif
  378.  
  379. #endif /* __DEVICES__ */
  380.